var e = require, t = module, n = exports;

Object.defineProperty(n, "__esModule", {
    value: !0
});

var o = e("GameConfig"), i = e("BaseView"), a = e("LoadManager"), r = function() {
    function e() {
        this.viewMap = new Map(), this.viewQueue = [], this.queue = [], this.barViews = [], 
        this.petShows = [], this.commonPnl = [ "air", "equip", "exp", "reward", "money", "diamond", "piece", "season", "season_reward", "egg_combine", "egg_get", "egg_reward", "draw_reward", "video_reward" ], 
        this.conflictPnl = [ "daily", "shop", "skin", "account", "battleAccount", "eggsWall", "eggsDesktop", "newActivity" ], 
        this.persistPnl = [ "privacyTips" ];
    }
    return e.getInstance = function() {
        return this._manager || (this._manager = new e()), this._manager;
    }, e.prototype.addPnl = function(e, t) {
        this.viewMap.set(e, t), this.viewQueue.includes(t) || (this.viewQueue.push(t), cc.systemEvent.emit("refreshCustomAd"));
    }, e.prototype.showPnl = function(e) {
        this.viewMap.has(e) && this.viewMap.get(e).showPnl();
    }, e.prototype.hidePnl = function(e) {
        this.viewMap.has(e) && this.viewMap.get(e).hidePnl();
    }, e.prototype.hidePnls = function(e) {
        var t = this;
        e.forEach(function(e) {
            t.viewMap.has(e) && t.viewMap.get(e).hidePnl();
        });
    }, e.prototype.hideAllPnl = function() {
        var t = this;
        Array.from(this.viewMap.values()).forEach(function(e) {
            t.persistPnl.includes(e.text) || e.hidePnl();
        });
    }, e.prototype.getPnl = function(e) {
        return this.viewMap.get(e);
    }, e.prototype.preloadPnl = function(e) {
        a.default.getInstance().loadRes({
            url: "pnl/" + e + "Pnl",
            type: cc.Prefab
        }).then(function(e) {
            console.log("preloadPnl success", e);
        }).catch(function(e) {
            console.error("preloadPnl fail", e);
        });
    }, e.prototype.loadPnl = function(l, r, u, c) {
        var d = this;
        return void 0 === r && (r = null), new Promise(function(i, e) {
            var t, n, s;
            -1 < o.GC.vaildpnl.indexOf(l) ? e() : "common" != l && d.viewMap.has(l) ? (s = d.viewMap.get(l), 
            d.viewQueue.includes(s) || (d.viewQueue.push(s), cc.systemEvent.emit("refreshCustomAd")), 
            i(s)) : -1 < d.queue.indexOf(l) ? (console.log(l + "is loading"), e()) : (GA.isPlatform(GA.Platform.Android) || null === (n = null === (t = GA.PA) || void 0 === t ? void 0 : t.showLoading) || void 0 === n || n.call(t, {
                title: "",
                mask: !1
            }), d.queue.push(l), a.default.getInstance().loadRes({
                url: "pnl/" + l + "Pnl",
                type: cc.Prefab
            }).then(function(e) {
                var t, n;
                GA.isPlatform(GA.Platform.Android) || null === (n = null === (t = GA.PA) || void 0 === t ? void 0 : t.hideLoading) || void 0 === n || n.call(t, {}), 
                u && u(e), i(d.initPnl(l, e, r));
            }).catch(function(e) {
                console.error("loadPnl fail", e), c && c(e);
            }));
        });
    }, e.prototype.initPnl = function(e, t, n) {
        t = cc.instantiate(t);
        n ? t.parent = n : cc.Canvas.instance.node.addChild(t);
        n = this.queue.indexOf(e);
        -1 < n && this.queue.splice(n, 1);
        n = t.getComponent(i.default);
        return n ? (this.viewMap.set(e, n), this.viewQueue.includes(n) || (this.viewQueue.push(n), 
        cc.systemEvent.emit("refreshCustomAd")), n) : t;
    }, e.prototype.loadPopPnl = function(e, t, n, i) {
        -1 < o.GC.vaildpnl.indexOf(e) || (PD.tag = e, PD.data = t, -1 < this.commonPnl.indexOf(e) ? this.loadPnl("common", i).then(function(e) {
            try {
                t && t.target && (e.target = t.target), n && n(e);
            } catch (e) {}
        }) : this.loadPnl(e, i).then(function(e) {
            try {
                n && n(e);
            } catch (e) {}
        }));
    }, e.prototype.deletePnl = function(e) {
        var t;
        this.viewMap.has(e) && (t = this.viewMap.get(e), -1 < (t = this.viewQueue.indexOf(t)) && this.viewQueue.splice(t, 1), 
        cc.systemEvent.emit("refreshCustomAd"), this.viewMap.delete(e));
    }, e.prototype.releasePnl = function(e) {
        var t = this;
        a.default.getInstance().releaseRes({
            url: "pnl/" + e + "Pnl",
            success: function() {
                t.deletePnl(e);
            }
        });
    }, e.prototype.showToast = function(t, n) {
        this.loadPnl("msg").then(function(e) {
            e instanceof i.default && e.init(t), n && n();
        });
    }, e.prototype.changeBtn = function() {}, e._manager = null, e;
}();

n.default = r;